import Vue from "vue";
import Router from "vue-router";
import Index from "@/pages/Index";

const Login = (resolve) => require(["@/pages/Login"], resolve);
const SignUp = (resolve) => require(["@/pages/SignUp"], resolve);
const ForgetPassword = (resolve) =>
    require(["@/pages/ForgetPassword"], resolve);
const GoodsList = (resolve) => require(["@/pages/GoodsList"], resolve);
const GoodsDetail = (resolve) => require(["@/pages/GoodsDetail"], resolve);
const PointGoodsDetail = (resolve) =>
    require(["@/pages/promotion/PointGoodsDetail"], resolve);
const ShoppingCart = (resolve) => require(["@/pages/ShoppingCart"], resolve);
const Cart = (resolve) => require(["@/pages/Cart"], resolve);
const Pay = (resolve) => require(["@/pages/payment/Pay"], resolve);
const PayDone = (resolve) => require(["@/pages/payment/PayDone"], resolve);
const UpLoadPage = (resolve) => require(["@/pages/payment/UpLoadPage"], resolve);

const PayMent = (resolve) => require(["@/pages/payment/PayMent"], resolve);
const ThirdPay = (resolve) => require(["@/pages/payment/ThirdPay"], resolve);
const Coupon = (resolve) => require(["@/pages/CouponCenter"], resolve);
const seckill = (resolve) => require(["@/pages/promotion/seckill"], resolve);
const article = (resolve) => require(["@/pages/article/index"], resolve);
const myArticle = (resolve) => require(["@/pages/article/myArticle.vue"], resolve);

const myOtherContent = (resolve) => require(["@/pages/article/myOtherContent.vue"], resolve);
const articleDetail = (resolve) => require(["@/pages/article/detail"], resolve);
const PosPay = (resolve) => require(["@/pages/payment/PosPay"], resolve);
const PointMall = (resolve) =>
    require(["@/pages/promotion/PointMall"], resolve);

/*
 * 會員中心
 * 訂單列表
 */
const MyOrder = (resolve) =>
    require([`@/pages/home/orderCenter/MyOrder`], resolve);
const OrderDetail = (resolve) =>
    require([`@/pages/home/orderCenter/OrderDetail`], resolve);
const MyAddress = (resolve) =>
    require(["@/pages/home/orderCenter/MyAddress"], resolve);
const AddAddress = (resolve) =>
    require(["@/pages/home/orderCenter/AddAddress"], resolve);
const Complain = (resolve) =>
    require(["@/pages/home/orderCenter/Complain"], resolve);
const AfterSale = (resolve) =>
    require(["@/pages/home/orderCenter/AfterSale"], resolve);
const AfterSaleDetail = (resolve) =>
    require(["@/pages/home/orderCenter/AfterSaleDetail"], resolve);
const ApplyAfterSale = (resolve) =>
    require(["@/pages/home/orderCenter/ApplyAfterSale"], resolve);

/*
 * 會員中心
 */
const Profile = (resolve) =>
    require(["@/pages/home/memberCenter/Profile"], resolve);
const AccountSafe = (resolve) =>
    require(["@/pages/home/memberCenter/AccountSafe"], resolve);
const ModifyPwd = (resolve) =>
    require(["@/pages/home/memberCenter/ModifyPwd"], resolve);
const Favorites = (resolve) =>
    require(["@/pages/home/memberCenter/Favorites"], resolve);
const Distribution = (resolve) =>
    require(["@/pages/home/memberCenter/Distribution"], resolve);
const CommentList = (resolve) =>
    require(["@/pages/home/memberCenter/CommentList"], resolve); // 評價列表
const AddEval = (resolve) =>
    require(["@/pages/home/memberCenter/evaluation/AddEval"], resolve); // 添加評價
const EvalDetail = (resolve) =>
    require(["@/pages/home/memberCenter/evaluation/EvalDetail"], resolve);
const ComplainList = (resolve) =>
    require(["@/pages/home/memberCenter/ComplainList"], resolve);
const ComplainDetail = (resolve) =>
    require(["@/pages/home/memberCenter/ComplainDetail"], resolve);
const Point = (resolve) =>
    require(["@/pages/home/memberCenter/Point"], resolve);
const MsgList = (resolve) =>
    require(["@/pages/home/memberCenter/memberMsg/MsgList"], resolve);
const MsgDetail = (resolve) =>
    require(["@/pages/home/memberCenter/memberMsg/MsgDetail"], resolve);

/*
 * 會員中心
 * 账戶中心
 * */
const Coupons = (resolve) =>
    require(["@/pages/home/userCenter/Coupons"], resolve);
const MyTracks = (resolve) =>
    require(["@/pages/home/userCenter/MyTracks"], resolve);
const MoneyManagement = (resolve) =>
    require(["@/pages/home/userCenter/MoneyManagement"], resolve);

const Home = (resolve) => require(["@/pages/user/Home"], resolve);

const Merchant = (resolve) => require(["@/pages/Merchant"], resolve);
const UserMain = (resolve) => require(["@/pages/home/Main"], resolve);


/*
 * 郵電通知
 * */
const Email = (resolve) =>
    require(["@/pages/home/email/Email"], resolve);


/*
 * 博客中心
 * */
//本人博客
const myBlog = (resolve) =>
    require(["@/pages/home/blog/myBlog"], resolve);
//他人博客
const othersBlog = (resolve) =>
    require(["@/pages/home/blog/othersBlog"], resolve);


/**
 * 店铺入驻
 */
const ShopEntry = (resolve) =>
    require(["@/pages/shopEntry/ShopEntry"], resolve);

Vue.use(Router);

/**
 * 解决重复點擊菜單会控制台报错bug
 */
const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return routerPush.call(this, location).catch(error => error)
}

export default new Router({
    mode: "history",
    routes: [
        {
            path: "/", // 首頁
            name: "Index",
            component: Index,
        },
        {
            path: "/login", // 登陆
            name: "login",
            component: Login,
            meta: {
                title: "登錄",
            },
        },
        {
            path: "/SignUp", // 註冊
            name: "SignUp",
            component: SignUp,
            meta: {
                title: "註冊",
            },
        },
        {
            path: "/forgetPassword", // 忘記密碼
            name: "forgetPassword",
            component: ForgetPassword,
            meta: {
                title: "忘記密碼",
            },
        },
        {
            path: "/goodsList", // 商品列表
            name: "GoodsList",
            component: GoodsList,
        },
        {
            path: "/goodsDetail", // 商品詳情
            name: "GoodsDetail",
            component: GoodsDetail,
            meta: {title: "商品詳情"},
        },
        {
            path: "/pointGoodsDetail", // 商品詳情
            name: "PointGoodsDetail",
            component: PointGoodsDetail,
            meta: {title: "積分商品"},
        },
        {
            path: "/shoppingCart", // 頭部購物車
            name: "ShoppingCart",
            component: ShoppingCart,
        },
        {
            path: "/cart", // 購物車
            name: "Cart",
            component: Cart,
            meta: {title: "購物車"},
        },
        {
            path: "/pay", // 支付頁面
            name: "Pay",
            component: Pay,
            meta: {title: "訂單结算"},
        },
        {
            path: "/payMent",
            name: "PayMent",
            component: PayMent,
        },
        {
            path: "/PointMall",
            name: "PointMall",
            component: PointMall,
            meta: {title: "積分商城"},
        },
        {
            path: "/pospay", // Pos支付
            name: "pospay",
            component: PosPay,
        },
        {
            path: "/qrpay", // 三方支付
            name: "qrpay",
            component: ThirdPay,
        },
        {
            path: "/payDone", // 支付成功頁面
            name: "PayDone",
            component: PayDone,
        },
      {
        path: "/UpLoadPage", // 支付成功頁面
        name: "UpLoadPage",
        component: UpLoadPage,
      },
        {
            path: "/article", // 文章頁面
            name: "article",
            component: article,
            meta: {
                title: "帮助中心",
            },
        },
        {
            path: "/myArticle", // 文章頁面
            name: "myArticle",
            component: myArticle,
            meta: {
                title: "帮助中心",
            },
        },
      {
        path: "/myOtherContent/:id", // 文章頁面
        name: "myOtherContent",
        component: myOtherContent,
        meta: {
          title: "其他内容",
        },
      },
        {
            path: "/article/detail", // 文章頁面
            name: "articleDetail",
            component: articleDetail,
            meta: {
                title: "帮助中心",
            },
        },
        {
            path: "/shopEntry",
            name: "shopEntry",
            component: ShopEntry,
            meta: {
                title: "店铺入驻",
            },
        },
        {
            path: "/coupon",
            name: "coupon",
            component: Coupon,
            meta: {
                title: "领券中心",
            },
        },
        {
            path: "/seckill",
            name: "seckill",
            component: seckill,
            meta: {
                title: "限時秒殺",
            },
        },
        {
            path: "/home", // 主頁
            component: Home,
            children: [
                {
                    path: "/",
                    name: "Home",
                    component: UserMain,
                    meta: {
                        title: "會員中心",
                    },
                },
                {
                    path: "MyTracks",
                    name: "MyTracks",
                    component: MyTracks,
                    meta: {title: "我的足跡"},
                },
                {
                    path: "MoneyManagement",
                    name: "MoneyManagement",
                    component: MoneyManagement,
                },
                {
                    path: "Complain",
                    name: "Complain",
                    component: Complain,
                },
                {
                    path: "Coupons",
                    name: "Coupons",
                    component: Coupons,
                },
                {
                    path: "CommentList",
                    name: "CommentList",
                    component: CommentList,
                    mate: {title: "評價列表"},
                },
                {
                    path: "AddEval",
                    name: "AddEval",
                    component: AddEval,
                    mate: {title: "添加評價"},
                },
                {
                    path: "EvalDetail",
                    name: "EvalDetail",
                    component: EvalDetail,
                    mate: {title: "評價詳情"},
                },
                {
                    path: "ComplainList",
                    name: "ComplainList",
                    component: ComplainList,
                },
                {
                    path: "ComplainDetail",
                    name: "ComplainDetail",
                    component: ComplainDetail,
                },
                {
                    path: "AccountSafe",
                    name: "AccountSafe",
                    component: AccountSafe,
                },
                {
                    path: "ModifyPwd",
                    name: "ModifyPwd",
                    component: ModifyPwd,
                },
                {
                    path: "Favorites",
                    name: "Favorites",
                    component: Favorites,
                    meta: {title: "我的收藏"},
                },
                {
                    path: "Distribution",
                    name: "Distribution",
                    component: Distribution,
                    meta: {title: "分销推薦"},
                },
                {
                    path: "Point",
                    name: "Point",
                    component: Point,
                    meta: {title: "我的積分"},
                },
                {
                    path: "Profile",
                    name: "Profile",
                    component: Profile,
                },
                {
                    path: "AfterSale",
                    name: "AfterSale",
                    component: AfterSale,
                    meta: {title: "售後"},
                },
                {
                    path: "ApplyAfterSale",
                    name: "ApplyAfterSale",
                    component: ApplyAfterSale,
                    meta: {title: "申請售後"},
                },
                {
                    path: "/home/MyAddress",
                    name: "MyAddress",
                    component: MyAddress,
                    meta: {title: "收貨地址"},
                },
                {
                    path: "AddAddress",
                    name: "AddAddress",
                    component: AddAddress,
                },
                {
                    path: "MsgList",
                    name: "MsgList",
                    component: MsgList,
                    meta: {title: "我的消息"},
                },
                {
                    path: "MsgDetail",
                    name: "MsgDetail",
                    component: MsgDetail,
                    meta: {title: "我的消息"},
                },
                {
                    path: "MyOrder",
                    name: "MyOrder",
                    component: MyOrder,
                    meta: {title: "我的訂單"},
                },
                {
                    path: "OrderDetail",
                    name: "OrderDetail",
                    component: OrderDetail,
                    meta: {title: "訂單詳情"},
                },
                {
                    path: "AfterSaleDetail",
                    name: "AfterSaleDetail",
                    component: AfterSaleDetail,
                    meta: {title: "售後詳情"},
                },
                {
                    path: "Email",
                    name: "Email",
                    component: Email,
                    meta: {
                        title: "郵電詳情",
                    },
                },
                {
                    path: "myBlog",
                    name: "myBlog",
                    component: myBlog,
                    meta: {
                        title: "我的博客",
                    },
                },
                {
                    path: "othersBlog",
                    name: "othersBlog",
                    component: othersBlog,
                    meta: {
                        title: "別人博客",
                    },
                },
            ],
        },
        {
            path: "/merchant",
            name: "Merchant",
            component: Merchant,
            meta: {title: "店铺"},
        },
    ],
});
